Skip to main content

systemctl command

systemctl - Control the systemd system and service manager

The systemctl command in Linux is the primary tool for managing services, units, and the system state on systems using systemd, the modern init system found in most current Linux distributions (e.g., Ubuntu, Debian, Fedora, CentOS). It allows you to start, stop, restart, enable, disable, and inspect services and other system components.

Usage: systemctl [OPTIONS...] COMMAND [UNIT...]

  • COMMAND: The action to perform (e.g., start, stop, status).
  • UNIT: The target of the action (e.g., ssh.service, network.target).
  • OPTIONS: Flags that modify behavior (less common).

Common Commands

CommandDescription
startStart a service
stopStop a service
restartRestart a service
reloadReload configuration
statusCheck service status
enableEnable service at boot
disableDisable service at boot
is-activeCheck if running (returns active or inactive)
is-enabledCheck if enabled at boot

Examples

  • Basic Service Management

    Control services like web servers, SSH, or databases with these core commands.

    Start a Service:

    sudo systemctl start ssh.service
    • Starts the SSH service (often sshd.service on some systems).

    Stop a Service:

    sudo systemctl stop ssh.service
    • Stops the SSH service.

    Restart a Service:

    sudo systemctl restart ssh.service
    • Stops and then starts the service.

    Reload a Service:

    sudo systemctl reload ssh.service
    • Reloads configuration without interrupting the service (if supported).

    Check Status:

    systemctl status ssh.service
    • Output (example):
      ● ssh.service - OpenBSD Secure Shell server
      Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
      Active: active (running) since Tue 2025-04-01 10:00:00 UTC; 1h ago
      Main PID: 1234 (sshd)
    • Shows if it’s running, PID, and recent logs.

    Note: .service is optional—systemctl status ssh works too.

  • Enabling and Disabling Services

    Control whether a service starts automatically at boot.

    Enable a Service:

    sudo systemctl enable ssh.service
    • Sets the service to start on boot.

    Disable a Service:

    sudo systemctl disable ssh.service
    • Prevents the service from starting on boot.

    Check Enabled Status:

    systemctl is-enabled ssh.service
    • Output: enabled or disabled.
  • Listing Units

    See what’s running or available on your system.

    List Active Services:

    systemctl list-units --type=service
    • Shows all active services (e.g., ssh.service, nginx.service).

    List All Services:

    systemctl list-units --type=service --all
    • Includes stopped services.

    List Unit Files:

    systemctl list-unit-files --type=service
    • Shows all service files and their enabled/disabled state (e.g., enabled, disabled, static).
  • System-Level Commands

    Manage the entire system with systemctl.

    Reboot:

    sudo systemctl reboot

    Power Off:

    sudo systemctl poweroff

    Suspend:

    sudo systemctl suspend
  • Viewing Logs

    Pair systemctl with journalctl for detailed logs.

    Service Logs:

    journalctl -u ssh.service
    • Shows logs for the SSH service.

    Recent Logs:

    journalctl -u ssh.service -n 10
    • Last 10 lines of logs.

To get help related to the systemctl command use --help option

For more details, check the manual with man systemctl